package com.aaa.three.service.impl;

import com.aaa.three.mapper.HospitalNewsMapper;
import com.aaa.three.pojo.domain.News;
import com.aaa.three.pojo.domain.NewsColumnTwo;
import com.aaa.three.pojo.vo.NewsVO;
import com.aaa.three.result.AjaxResult;
import com.aaa.three.service.HospitalNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class HospitalNewsServiceImpl implements HospitalNewsService {

    @Autowired
    private HospitalNewsMapper hospitalNewsMapper;

    /**
     *  查询新闻
     */
    @Override
    public AjaxResult queryHospitalNews() {
        List<News> news = hospitalNewsMapper.queryHospitalNews();
        return AjaxResult.success(news);
    }

    /**
     *  查询 新闻栏目相同的 新闻
     */
    @Override
    public AjaxResult listHospitalNews(Integer ncolumn) {
        List<NewsVO> news = hospitalNewsMapper.listHospitalNews(ncolumn);
        Long aLong = hospitalNewsMapper.listNewsTotal(ncolumn);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("currentData", news);
        map.put("totalCount", aLong);
        return AjaxResult.success(map);
    }

    /**
     *  查询新闻栏目
     */
    @Override
    public AjaxResult listHospitalNewsColumn(Integer id) {
        NewsColumnTwo newsColumnTwo = hospitalNewsMapper.listHospitalNewsColumn(id);
        return AjaxResult.success(newsColumnTwo);
    }

    /**
     *  医院新闻首页的 欢迎页
     */
    @Override
    public AjaxResult hospitalNewsWelcomePage() {
        List<NewsVO> newsVO = hospitalNewsMapper.hospitalNewsWelcomePage();
        Long aLong = hospitalNewsMapper.hospitalNewsWelcomePageTotal();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("currentData", newsVO);
        map.put("totalCount", aLong);
        return AjaxResult.success(map);
    }

    /**
     *  主页展示 新闻媒体
     */
    @Override
    public AjaxResult listNewsMedia() {
        List<NewsVO> newsVO = hospitalNewsMapper.listNewsMedia();
        return AjaxResult.success(newsVO);
    }

    /**
     *  主页展示 通知公告
     */
    @Override
    public AjaxResult listAnnouncement() {
        List<NewsVO> newsVO = hospitalNewsMapper.listAnnouncement();
        return AjaxResult.success(newsVO);
    }

    /**
     *  主页展示 置顶的新闻
     */
    @Override
    public AjaxResult listNewsOnTop() {
        List<NewsVO> newsVO = hospitalNewsMapper.listNewsOnTop();
        return AjaxResult.success(newsVO);
    }

}
